import traceback
try:
    from dopplershift.backend.frontends.http import DSJSONHttpHandler
    from twisted.web.server import NOT_DONE_YET
    import txmongo
    
    
    class OloloPlugin(DSJSONHttpHandler):
        name = "ololo"
        
        def pewpew(self, request):
            collection = self._db.getCollection('delivering')
            f = txmongo.filter.sort(txmongo.filter.DESCENDING("created"))
            d = collection.find({}, filter=f)
            d.addCallback(self._pewpew, request)
            return NOT_DONE_YET
        def _pewpew(self, result, request):
            self._render( request, result)
    app = OloloPlugin()
except:
    print "Backend examples not loaded"